<?php

class Application_Controllers_PersonController
{
    
    public function __construct($action) 
    {
        switch ($action) {
            case 'show':
                $this->_show();
                break;
            case 'query':
                $this->_query();
                break;
            case 'insert':
                $this->_insert();
                break;
            default:
               $this->_query();
                break;
        }    
        
    }
    
    private function _query(){
        $modelPerson=new Application_Models_PersonModel();
        $modelPerson->consultPerson();
    }
    
    private function _insert()
    {
     
        $viewPerson = new Application_Views_PersonView();
        $viewPerson->insertAge();
        
    }
    
    private function _show()
    {
      $year = $_GET['txtYear'];
        
      $modelPerson = new Application_Models_PersonModel();
      $age =  $modelPerson->calculateAge($year);

      $viewPerson = new Application_Views_PersonView();
      $viewPerson->showAge($age);
    }
    
}